package com.heaven.jane.sourcegenerator.commons.security.authority.service;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.heaven.jane.sourcegenerator.commons.security.authority.dao.AuthorityRepository;
import com.heaven.jane.sourcegenerator.commons.security.authority.dao.AuthoritySpec;
import com.heaven.jane.sourcegenerator.commons.security.authority.domain.Authority;
import com.heaven.jane.sourcegenerator.commons.security.user.domain.User;

/**
 * 用户业务类
 * 
 * @author heaven
 *
 */
@Service
public class AuthorityServiceImpl implements AuthorityService {

	@Autowired
	private AuthorityRepository authorityRepository;

	@Override
	public List<Authority> findByUserId(Long userId) {
		return authorityRepository.findAll(
				AuthoritySpec.builder().userCondition(Optional.ofNullable(User.builder().id(userId).build())).build());
	}

}
